﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TAE04
    {

        public TAE04()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VMEKOPF();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateMEKOPF(dwMaster, 0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }

        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length < 35)
                return;
            dwData = TMV.TBMain.NewRow(); 
            dwData["MEKMANDANT"] = app.Mandant;
            dwData["MEKAGANG"] = "AND MEKAGANG= '" + ORDERNUM.Substring(0, 15) + "'";
            dwData["MEKMTYP"] = "AND MEKMTYP= '" + ORDERNUM.Substring(15, 8) + "'";
            dwData["MEKMNRKRS"] = "AND MEKMNRKRS= '" + ORDERNUM.Substring(23, 2) + "'";
            dwData["MEKMLFDNR"] = "AND MEKMLFDNR= '" + ORDERNUM.Substring(25, 4) + "'";
            dwData["MEKMPOS"] = "AND MEKMPOS= '" + ORDERNUM.Substring(29, 2) + "'";
            dwData["MEKEVARHNR"] = "AND MEKEVARHNR= '" + ORDERNUM.Substring(31, 2) + "'";
            dwData["MEKEVARUNR"] = "AND MEKEVARUNR= '" + ORDERNUM.Substring(33, 2) + "'"; 
            SResult = TMV.QMAE02(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        } 
        
    }
}
